home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Unix / Shells / tcsh / Source / ed.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-02-21  |  8.5 KB  |  240 lines

  1. /* $Header: /u/christos/src/tcsh-6.03/RCS/ed.h,v 3.20 1992/10/05 02:41:30 christos Exp $ */
  2. /*
  3.  * ed.h: Editor declarations and globals
  4.  */
  5. /*-
  6.  * Copyright (c) 1980, 1991 The Regents of the University of California.
  7.  * All rights reserved.
  8.  *
  9.  * Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions
  11.  * are met:
  12.  * 1. Redistributions of source code must retain the above copyright
  13.  *    notice, this list of conditions and the following disclaimer.
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in the
  16.  *    documentation and/or other materials provided with the distribution.
  17.  * 3. All advertising materials mentioning features or use of this software
  18.  *    must display the following acknowledgement:
  19.  *    This product includes software developed by the University of
  20.  *    California, Berkeley and its contributors.
  21.  * 4. Neither the name of the University nor the names of its contributors
  22.  *    may be used to endorse or promote products derived from this software
  23.  *    without specific prior written permission.
  24.  *
  25.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  26.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  27.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  28.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  29.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  30.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  31.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  32.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  33.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  34.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  35.  * SUCH DAMAGE.
  36.  */
  37. #ifndef _h_ed
  38. #define _h_ed
  39.  
  40. #ifndef EXTERN
  41. # define EXTERN extern
  42. #endif
  43.  
  44. #define TABSIZE        8    /* usually 8 spaces/tab */
  45. #define MAXMACROLEVELS    10    /* max number of nested kbd macros */
  46.  
  47. extern int errno;
  48.  
  49. /****************************************************************************/
  50. /* stuff for the different states returned by the character editor routines */
  51. /****************************************************************************/
  52.  
  53. #define CCRETVAL    char    /* size needed for the different char editor */
  54.  /* return values */
  55.  
  56. #define KEYCMD   unsigned char    /* size needed to index into CcFuncTbl */
  57.  /* Must be unsigned                */
  58.  
  59. typedef CCRETVAL(*PFCmd) __P((int));    /* pointer to function returning CCRETVAL */
  60.  
  61. struct KeyFuncs {        /* for the "bind" shell command */
  62.     char   *name;        /* function name for bind command */
  63.     int     func;        /* function numeric value */
  64.     char   *description;    /* description of function */
  65. };
  66.  
  67. extern PFCmd CcFuncTbl[];    /* table of available commands */
  68. extern KEYCMD CcKeyMap[];    /* keymap table, each index into above tbl */
  69. extern KEYCMD CcAltMap[];    /* Alt keymap table */
  70. extern KEYCMD CcEmacsMap[];    /* keymap table for Emacs default bindings */
  71. extern KEYCMD CcViCmdMap[];    /* for Vi command mode defaults */
  72. extern struct KeyFuncs FuncNames[];    /* string names vs. CcFuncTbl indices */
  73.  
  74. extern KEYCMD NumFuns;        /* number of KEYCMDs in above table */
  75.  
  76. #define    CC_ERROR        100    /* there should NOT be 100 different... */
  77. #define CC_FATAL        101    /* fatal error: inconsistant, must
  78.                      * reset */
  79. #define    CC_NORM            0
  80. #define    CC_NEWLINE        1
  81. #define    CC_EOF            2
  82. #define    CC_COMPLETE        3
  83. #define    CC_LIST_CHOICES        4
  84. #define    CC_LIST_GLOB        5
  85. #define CC_EXPAND_GLOB        6
  86. #define    CC_HELPME        9
  87. #define CC_CORRECT        10
  88. #define CC_WHICH        11
  89. #define CC_ARGHACK        12
  90. #define CC_CORRECT_L        13
  91. #define CC_REFRESH        14
  92. #define CC_EXPAND_VARS        15
  93. #define CC_NORMALIZE_PATH    16
  94. #define CC_LIST_ALL        17
  95. #define CC_COMPLETE_ALL        18
  96.  
  97. typedef union Xmapval {        /* value passed to the Xkey routines */
  98.     KEYCMD cmd;
  99.     Char *str;
  100. } XmapVal;
  101.  
  102. #define XK_NOD    -1        /* Internal tree node */
  103. #define XK_CMD     0        /* X-key was an editor command */
  104. #define XK_STR     1        /* X-key was a string macro */
  105. #define XK_EXE     2        /* X-key was a unix command */
  106.  
  107. /****************************/
  108. /* Editor state and buffers */
  109. /****************************/
  110.  
  111. EXTERN KEYCMD *CurrentKeyMap;    /* current command key map */
  112. EXTERN int inputmode;        /* insert, replace, replace1 mode */
  113. EXTERN Char GettingInput;    /* true if getting an input line (mostly) */
  114. EXTERN Char NeedsRedraw;    /* for editor and twenex error messages */
  115. EXTERN Char InputBuf[INBUFSIZE];    /* the real input data */
  116. EXTERN Char *LastChar, *Cursor;    /* point to the next open space */
  117. EXTERN Char *InputLim;        /* limit of size of InputBuf */
  118. EXTERN Char MetaNext;        /* flags for ^V and ^[ functions */
  119. EXTERN Char AltKeyMap;        /* Using alternative command map (for vi mode) */
  120. EXTERN Char VImode;        /* true if running in vi mode (PWP 6-27-88) */
  121. EXTERN Char *Mark;        /* the emacs "mark" (dot is Cursor) */
  122. EXTERN Char DoingArg;        /* true if we have an argument */
  123. EXTERN int Argument;        /* "universal" argument value */
  124. EXTERN KEYCMD LastCmd;        /* previous command executed */
  125. EXTERN Char KillBuf[INBUFSIZE];    /* kill buffer */
  126. EXTERN Char *LastKill;        /* points to end of kill buffer */
  127.  
  128. EXTERN Char UndoBuf[INBUFSIZE];
  129. EXTERN Char *UndoPtr;
  130. EXTERN int  UndoSize;
  131. EXTERN int  UndoAction;
  132.  
  133. EXTERN Char HistBuf[INBUFSIZE];    /* history buffer */
  134. EXTERN Char *LastHist;        /* points to end of history buffer */
  135. EXTERN int Hist_num;        /* what point up the history we are at now. */
  136. EXTERN Char WhichBuf[INBUFSIZE];    /* buffer for which command */
  137. EXTERN Char *LastWhich;        /* points to end of which buffer */
  138. EXTERN Char *CursWhich;        /* points to the cursor point in which buf */
  139. EXTERN int HistWhich;        /* Hist_num is saved in this */
  140. EXTERN char Expand;        /* true if we are expanding a line */
  141. extern Char HistLit;        /* true if history lines are shown literal */
  142. EXTERN Char CurrentHistLit;    /* Literal status of current show history line */
  143.  
  144. /*
  145.  * These are truly extern
  146.  */
  147. extern Char PromptBuf[];
  148. extern int MacroLvl;
  149.  
  150. EXTERN Char *KeyMacro[MAXMACROLEVELS];
  151.  
  152. EXTERN Char **Display;        /* display buffer seed vector */
  153. EXTERN int CursorV,        /* real cursor vertical (line) */
  154.         CursorH,        /* real cursor horisontal (column) */
  155.         TermV,            /* number of real screen lines
  156.                  * (sizeof(DisplayBuf) / width */
  157.         TermH;            /* screen width */
  158. EXTERN Char **Vdisplay;        /* new buffer */
  159.  
  160. /* Variables that describe terminal ability */
  161. EXTERN int T_Lines, T_Cols;    /* Rows and Cols of the terminal */
  162. EXTERN Char T_CanIns;        /* true if I can insert characters */
  163. EXTERN Char T_CanDel;        /* dito for delete characters */
  164. EXTERN Char T_Tabs;        /* true if tty interface is passing tabs */
  165. EXTERN Char T_Margin;        
  166. #define MARGIN_AUTO  1        /* term has auto margins */
  167. #define MARGIN_MAGIC 2        /* concept glitch */
  168. EXTERN speed_t T_Speed;        /* Tty input Baud rate */
  169. EXTERN Char T_CanCEOL;        /* true if we can clear to end of line */
  170. EXTERN Char T_CanUP;        /* true if this term can do reverse linefeen */
  171. EXTERN Char T_HasMeta;        /* true if we have a meta key */
  172.  
  173. /* note the extra characters in the Strchr() call in this macro */
  174. #define isword(c)    (Isalpha(c)||Isdigit(c)||Strchr(word_chars,c))
  175. #define min(x,y)    (((x)<(y))?(x):(y))
  176. #define max(x,y)    (((x)>(y))?(x):(y))
  177.  
  178. /*
  179.  * Terminal dependend data structures
  180.  */
  181. typedef struct {
  182. #if defined(POSIX) || defined(TERMIO)
  183. # ifdef POSIX
  184.     struct termios d_t;
  185. # else
  186.     struct termio d_t;
  187. # endif /* POSIX */
  188. #else /* SGTTY */
  189. # ifdef TIOCGETP
  190.     struct sgttyb d_t;
  191. # endif /* TIOCGETP */
  192. # ifdef TIOCGETC
  193.     struct tchars d_tc;
  194. # endif /* TIOCGETC */
  195. # ifdef TIOCGPAGE
  196.     struct ttypagestat d_pc;
  197. # endif /* TIOCGPAGE */
  198. # ifdef TIOCLGET
  199.     int d_lb;
  200. # endif /* TIOCLGET */
  201. #endif /* POSIX || TERMIO */
  202. #ifdef TIOCGLTC
  203.     struct ltchars d_ltc;
  204. #endif /* TIOCGLTC */
  205. } ttydata_t;
  206.  
  207. #define MODE_INSERT    0
  208. #define MODE_REPLACE    1
  209. #define MODE_REPLACE_1    2
  210.  
  211. #define EX_IO    0    /* while we are executing    */
  212. #define ED_IO    1    /* while we are editing        */
  213. #define TS_IO    2    /* new mode from terminal    */
  214. #define QU_IO    2    /* used only for quoted chars    */
  215. #define NN_IO    3    /* The number of entries    */
  216.  
  217. #if defined(POSIX) || defined(TERMIO)
  218. # define M_INPUT    0
  219. # define M_OUTPUT    1
  220. # define M_CONTROL    2
  221. # define M_LINED    3
  222. # define M_CHAR        4
  223. # define M_NN        5
  224. #else /* GSTTY */
  225. # define M_CONTROL    0
  226. # define M_LOCAL    1
  227. # define M_CHAR        2
  228. # define M_NN        3
  229. #endif /* TERMIO */
  230. typedef struct { 
  231.     char *t_name;
  232.     int  t_setmask;
  233.     int  t_clrmask;
  234. } ttyperm_t[NN_IO][M_NN];
  235.  
  236. extern ttyperm_t ttylist;
  237. #include "ed.decls.h"
  238.  
  239. #endif /* _h_ed */
  240.